Skip to content

Avoid duplicate Platform initializer in generated JavaScript#98

Closed
derrickbeining wants to merge 1 commit into
lamdera:lamdera-nextfrom
derrickbeining:fix/no-wire-platform-initialize-collision
Closed

Avoid duplicate Platform initializer in generated JavaScript#98
derrickbeining wants to merge 1 commit into
lamdera:lamdera-nextfrom
derrickbeining:fix/no-wire-platform-initialize-collision

Conversation

@derrickbeining

Copy link
Copy Markdown

Summary

  • Rename Lamdera's replacement Platform initializer to _Platform_initialize_Lamdera before kernel chunks are emitted.
  • Rewrite Lamdera replacement Browser/Debugger/Platform call sites to use that Lamdera-specific initializer name.
  • Keep the existing Lamdera Live HTTP kernel patch scoped to Lamdera Live builds only.

Fixes #97.

Why

lamdera make --no-wire currently emits a second global _Platform_initialize from the Lamdera replacement elm/core kernel. Downstream tooling such as elm-watch patches the standard compiler _Platform_initialize, but the later Lamdera declaration can override that patched function at runtime.

Using a Lamdera-specific initializer name preserves Lamdera's replacement runtime behavior without shadowing the compiler runtime name that downstream tools may patch.

Test plan

  • Verified in a downstream Elm Land app that raw Lamdera output currently contains two _Platform_initialize definitions and that elm-watch rewrites only the first.
  • Verified that renaming the Lamdera replacement initializer removes the duplicate active _Platform_initialize shape from transformed output.
  • Attempted stack build --fast locally. The build did not reach this change; it failed in third-party C/native dependencies on macOS (hashable, hfsevents, entropy) against the local SDK/toolchain.

Made with Cursor

Rename Lamdera's replacement Platform initializer and call sites so generated output no longer emits a second global _Platform_initialize that can shadow downstream tooling patches.
@derrickbeining

Copy link
Copy Markdown
Author

Closing this initial compiler-side rewrite in favor of the package-replacement workflow documented in extra/readme.md. The replacement-package PRs are now open at lamdera/elm-core#1 and lamdera/elm-browser#1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lamdera make --no-wire emits duplicate _Platform_initialize, breaking elm-watch/Elm Land dev builds

1 participant